package org.primefaces.examples.mobile;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class DropFileAdmin implements Serializable{

	
	
	public DropFileAdmin() {
			
	}
	
	private String name = "Luigi";

	private String surname = "Toziani";
	
	private String email = "luigi.toziani@primeur.com";
	
	
	private boolean returnRecipt = true;

	private boolean isPublic = false;
	
	private boolean deleteAfterDownload = false;
	
	private Date defaultExpiryDate = new Date();

	private List<String> lastUsedAddressList = new ArrayList<String>();
	
	private static final SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy");

	private static final SimpleDateFormat defaultDateFormat = new SimpleDateFormat("dd/MM/yy");
	
	
	
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public boolean isReturnRecipt() {
		return returnRecipt;
	}

	public void setReturnRecipt(boolean returnRecipt) {
		this.returnRecipt = returnRecipt;
	}

	public boolean isPublic() {
		return isPublic;
	}

	public void setPublic(boolean isPublic) {
		this.isPublic = isPublic;
	}

	public boolean isDeleteAfterDownload() {
		return deleteAfterDownload;
	}

	public void setDeleteAfterDownload(boolean deleteAfterDownload) {
		this.deleteAfterDownload = deleteAfterDownload;
	}

	public Date getDefaultExpiryDate() {
		return defaultExpiryDate;
	}

	public void setDefaultExpiryDate(Date defaultExpiryDate) {
		this.defaultExpiryDate = defaultExpiryDate;
	}
	
	
	public String getMinExpiryDate()
	{
		
		return sdf.format(new Date());
		
	}
	
	public String getFormattedExpiryDate()
	{
		return defaultDateFormat.format(defaultExpiryDate);
	}
	
	public void update() {
        FacesMessage msg = new FacesMessage("User data updated");
		FacesContext.getCurrentInstance().addMessage(null, msg);
    }

	public void setLastUsedAddressList(List<String> lastUsedAddressList) {
		this.lastUsedAddressList = lastUsedAddressList;
	}

	public List<String> getLastUsedAddressList() {
		if(lastUsedAddressList.isEmpty())
		{
			lastUsedAddressList.add("luigi.toziani@primeur.com");
			lastUsedAddressList.add("luca.musso@primeur.com");
			lastUsedAddressList.add("massimo.gabellone@primeur.com");
			lastUsedAddressList.add("gabriele.piccinno@primeur.com");
			lastUsedAddressList.add("teresa.merlino@primeur.com");
		}
		return lastUsedAddressList;
	}
	
}
